import java.util.Stack;

/**
 * @author Summerday
 */
public class T {
    public boolean canChoose(int[][] groups, int[] nums) {
        int st = 0;
        boolean flag = false;
        for(int[] g : groups){
            int idx = 0;
            if(st == nums.length) return false;
            for(int i = st; i < nums.length;){
                if(nums[i] == g[idx]){
                    idx ++;
                    i ++;
                }else{
                    i ++;
                    idx = 0;
                    continue;
                }
                if(idx == g.length) {
                    st = i;
                    flag = true;
                    break;
                }
            }
            if(!flag) return false;
        }

        return true;
    }

    public static void main (String[] args) {
        int[][] g = new int[][]{
                {1,-1,-1},{3,-2,0}
        };
        int[] a = {1,-1,0,1,-1,-1,3,-2,0};
        new T().canChoose(g,a);
    }
}
